package Test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
 
public class MainClass {
    public static void main(String[] a) {
        final Display display = new Display();
        final Shell shell = new Shell(SWT.NO_TRIM | SWT.NONE);
        shell.setText("Sash One");
        // The SWT.BORDER style
//        Decorations d = new Decorations(shell, SWT.NO_TRIM);
//        d.setLayoutData(new GridData(GridData.FILL_BOTH));
//        d.setLayout(new FillLayout());
//        Label l = new Label(d, SWT.CENTER);
//        l.setText("SWT.NO_TRIM");
//
//        d.setBounds(20, 20, 100, 100);
 
        shell.pack();
        shell.open();
 
        Display.getCurrent().addFilter(SWT.KeyDown, new Listener() {
            public void handleEvent(Event event) {
                if (event.keyCode == SWT.F4 && (event.stateMask & SWT.ALT) != 0) {
                    if (Display.getCurrent().getActiveShell() == shell) {
                        shell.close();
                    }
                }
            }
        });
//        shell.addListener(SWT.Deactivate, new Listener() {
//           
//            @Override
//            public void handleEvent(Event e) {
//                System.out.println(e.keyCode + " " + e.stateMask + " " + e.button + "" );
//                shell.setMinimized(true);
//            }
//        });
         
        shell.addListener(SWT.Close, new Listener() {
             
            @Override
            public void handleEvent(Event e) {
                System.out.println("fafafafa" + e.keyCode + " " + e.stateMask + " " + e.button + "" );
                shell.setMinimized(false);
            }
        });
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
}